/*
  SpiderWeb design tokens: the single source of truth for how every browser
  surface looks (website, admin console, provider pages and the desktop app).

  Three layers, each built from the one above it:
    1. Primitives   raw values: the ink color, the blue, the type sizes
    2. Semantics    what a value is for: --color-text-secondary, --radius-md
    3. Aliases      the names older website CSS already uses (--text-main,
                    --bg-surface, --primary ...), each pointing at a semantic

  To retheme, change a primitive. To change one role, change that semantic.
  Nothing else in the repo defines a color, size or radius of its own.

  Values come from the Figma frame "Desktop - 1" (SpiderWeb file). Anything
  marked "extension" is not in that frame; it exists so screens the frame
  does not show (forms, docs, landing) follow the same system.

  Accessibility notes (checked by uitheme_test.go):
    - Text uses --text-main / --text-muted, never the 40% ink tone, which is
      for placeholders and disabled states only.
    - The Figma status colors (green, red) are too light to carry text or fill
      on white, so text and filled controls use the darker -600 / -700 steps.
    - Filled blue buttons use the Figma blue exactly (operator decision
      2026-11-15), which measures 3.95:1 against white text.

  One light theme for every surface. The desktop app adds its own dark
  appearance on top (internal/desktop/web/css/theme.css) by re-pointing these
  primitives; the website has no dark mode.
*/

@font-face {
  font-family: 'Public Sans';
  src: url('PublicSans-Variable.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* ───────────── 1. Primitives ───────────── */

  /* Ink and paper are RGB triplets so every text, border and shadow tone is
     one color at a different opacity. */
  --ink-rgb: 13 13 13;
  --paper-rgb: 253 253 253;
  --blue-rgb: 0 122 255;
  --purple-rgb: 157 0 255;
  --green-rgb: 46 157 58;
  --red-rgb: 217 45 32;
  --amber-rgb: 138 75 8;

  --blue-500: #007aff; /* Figma accent: fills, focus, queued/running state */
  --blue-600: #0066d6; /* hover on a filled blue control */
  --blue-700: #0058b8; /* blue used as text on light backgrounds */
  --purple-500: #9d00ff;
  --green-500: #4bb543; /* Figma success: the status dot in the jobs table */
  --green-600: #2e9d3a; /* success as a fill */
  --green-700: #1f7a2b; /* success as text */
  --red-500: #ff3333; /* Figma failure: the status dot in the jobs table */
  --red-600: #d92d20; /* danger as a fill */
  --red-700: #b42318; /* danger as text */
  --amber-700: #8a4b08; /* warnings, as fill and text */
  --provider-700: #8a4b08; /* provider accent */
  --provider-800: #713b06;

  --blue-brand-1: #2468e6; /* hero gradient, light end: white text on it measures 5.0:1 */
  --blue-brand-2: #1560e8;
  --blue-brand-3: #0a52d8;

  --gray-50: #f9f9f9; /* page and sidebar */
  --gray-100: #f4f4f4; /* subtle surface */
  --gray-200: #e7e7e7; /* panel edge */
  --gray-300: #d9d9d9;

  /* Type */
  --font-sans: 'Public Sans', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  --font-features: 'ss01' 1; /* Public Sans stylistic set 1, on everywhere */
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;

  --text-xs: 0.75rem; /* 12, extension */
  --text-sm: 0.875rem; /* 14, extension: hints, captions, code */
  --text-base: 1rem; /* 16: body, labels, tables, navigation */
  --text-md: var(--text-base);
  --text-lg: 1.125rem; /* 18, extension */
  --text-xl: 1.25rem; /* 20: section titles */
  --text-2xl: 1.5rem; /* 24: page titles */
  --text-3xl: 2rem; /* 32, extension */
  --text-4xl: 2.75rem; /* 44, extension */
  --text-title: var(--text-xl);
  --text-heading: var(--text-2xl);
  --text-stat: 2.25rem; /* 36: big numbers */
  --text-hero: 3rem; /* 48, extension: landing */
  --text-display: 3.375rem; /* 54, extension: website hero headline */
  --text-display-xl: 4.5rem; /* 72, extension: the desktop start screen headline */
  --text-section: var(--text-4xl); /* 44: website section headlines */

  --leading-ui: 1rem; /* single-line interface text */
  --leading-tight: 1.1; /* titles and numbers */
  --leading-body: 1.5; /* extension: paragraphs and hints */
  --tracking-tight: -0.03em; /* titles and numbers */
  --tracking-display: -0.05em; /* extension: display and section headlines */

  /* Space: N x 4px, as rem so it follows the reader's text size */
  --space-1: 0.25rem;
  --space-1-5: 0.375rem;
  --space-2: 0.5rem;
  --space-2-5: 0.625rem; /* 10, extension */
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7-5: 1.875rem; /* 30, extension */
  --space-8: 2rem;
  --space-9: 2.25rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-15: 3.75rem;
  --space-16: 4rem;
  --space-18: 4.5rem; /* 72, extension */
  --space-20: 5rem;
  --space-24: 6rem;
  --space-30: 7.5rem; /* 120, extension: website section padding */

  /* Shape */
  --radius-xs: 4px;
  --radius-sm: 6px; /* checkbox, status dot */
  --radius-md: 8px; /* buttons, inputs, cards, nav items */
  --radius-lg: 12px; /* extension: dialogs, popovers */
  --radius-xl: 16px; /* extension */
  --radius-pill: 9999px;
  --radius-full: var(--radius-pill);

  /* Size */
  --size-icon: 1rem;
  --size-control: 2.25rem; /* button and input height */
  --size-control-lg: 2.5rem; /* extension: the website's marketing buttons */
  --size-stat-card: 7.5625rem;
  --size-avatar: 1rem;

  /* Desktop layout */
  --sidebar-width: 18rem; /* the default; the divider can change it per person */
  --sidebar-min: 200px;
  --sidebar-max: 480px;
  --content-width: 67.5rem;
  --content-gutter: 2.1875rem;
  --page-top: 3rem;
  --window-controls: 3.25rem; /* macOS traffic lights; reserved only in the Mac app */
  --sidebar-pad: 0.375rem;
  --fade-height: 3.75rem;

  /* Website layout (Figma frames: Hero + Navbar, S1 to S3, Footer; 1440 wide) */
  --site-width: 67.5rem; /* 1080 content column */
  --site-gutter: clamp(1.25rem, 5vw, 2rem); /* side room in narrow windows */
  --site-aside: 21.25rem; /* 340 headline column beside a section's content */
  --site-split-gap: 3.75rem; /* 60 between the two columns */

  /* Motion */
  --duration-fast: 120ms;
  --duration-base: 180ms;
  --motion-fast: 150ms cubic-bezier(0.16, 1, 0.3, 1);
  --motion-base: 200ms cubic-bezier(0.16, 1, 0.3, 1);

  /* ───────────── 2. Semantics ───────────── */

  /* Surfaces */
  --color-bg-sidebar: var(--gray-50);
  --color-bg-surface: rgb(var(--paper-rgb));
  --color-bg-subtle: rgb(var(--ink-rgb) / 0.03); /* active nav item, row hover */
  --color-bg-control: transparent;
  --color-bg-code: rgb(var(--ink-rgb) / 0.04);
  --color-bg-overlay: rgb(var(--ink-rgb) / 0.18);

  /* Text */
  --color-text-primary: rgb(var(--ink-rgb));
  --color-text-meta: rgb(var(--ink-rgb) / 0.69);
  --color-text-secondary: rgb(var(--ink-rgb) / 0.6);
  --color-text-tertiary: rgb(var(--ink-rgb) / 0.4); /* placeholders and disabled only */
  --color-text-on-accent: rgb(var(--paper-rgb));

  /* Lines */
  --color-border-edge: var(--gray-200);
  --color-border-card: rgb(var(--ink-rgb) / 0.12);
  --color-border-control: rgb(var(--ink-rgb) / 0.1);
  --color-divider: rgb(var(--ink-rgb) / 0.1);
  --color-border-input: rgb(var(--ink-rgb) / 0.55); /* controls that must meet 3:1 on the website */

  /* Accent and state */
  --color-accent: var(--blue-500);
  --color-accent-hover: var(--blue-600);
  --color-accent-text: var(--blue-700);
  --color-danger: var(--red-600);
  --color-warning: var(--amber-700);
  --color-success: var(--green-600);
  --color-accent-bg: rgb(var(--blue-rgb) / 0.07);
  --color-danger-bg: rgb(var(--red-rgb) / 0.07);
  --color-warning-bg: rgb(var(--amber-rgb) / 0.08);
  --color-success-bg: rgb(var(--green-rgb) / 0.09);

  /* Job status: the five tones of the jobs table (Figma values) */
  --status-queued: var(--purple-500);
  --status-running: var(--blue-500);
  --status-succeeded: var(--green-500);
  --status-failed: var(--red-500);
  --status-cancelled: var(--color-text-secondary);

  /* Elevation */
  --shadow-card: 0 1px 1px rgb(var(--ink-rgb) / 0.05);
  --shadow-control: 0 1px 2px rgb(var(--ink-rgb) / 0.05);
  --shadow-popover: 0 8px 24px rgb(var(--ink-rgb) / 0.12), 0 0 0 1px rgb(var(--ink-rgb) / 0.06); /* extension */

  /* Page wash: a faint accent glow from the top, fading over the first
     quarter of a 1024px-tall window, as in the frame. */
  --gradient-page: linear-gradient(180deg, rgb(var(--blue-rgb) / 0.05) 0%, rgb(var(--blue-rgb) / 0) 25.293%);
  --gradient-page-height: 1024px;

  /* Website washes: the hero fades from the top over its first half; the footer
     fades in toward the bottom. */
  --gradient-hero: linear-gradient(180deg, rgb(var(--blue-rgb) / 0.05) 0%, rgb(var(--blue-rgb) / 0) 50%);
  --gradient-footer: linear-gradient(180deg, rgb(var(--blue-rgb) / 0) 34.043%, rgb(var(--blue-rgb) / 0.05) 100%);

  /* The brand visual, for heroes only: a deep blue field with a soft light in
     the top-left corner. Text on it is paper-colored. */
  --gradient-brand: radial-gradient(ellipse 60% 70% at 0% 0%, rgb(255 255 255 / 0.07), transparent 60%),
    linear-gradient(115deg, var(--blue-brand-1) 0%, var(--blue-brand-2) 45%, var(--blue-brand-3) 100%);
  --color-text-on-brand: rgb(var(--paper-rgb));
  --color-text-on-brand-muted: rgb(var(--paper-rgb) / 0.88);
  --color-mark-on-brand: rgb(var(--paper-rgb) / 0.1); /* the large logomark behind a hero */

  /* Focus */
  --focus-outline: 2px solid var(--color-accent);
  --focus-offset: 2px;

  /* Text-box trim: seats a 16px label on its cap height and baseline, as in
     the frame. Ignored where unsupported. */
  --text-box: trim-both cap alphabetic;
  /* Trimmed text that also clips its overflow (for an ellipsis) would lose the
     tails of g, y, p and the tops of tall letters. These elements get this much
     room above and below, cancelled by an equal negative margin so layout is
     unchanged. */
  --text-clip-room: 0.3em;

  /* ───────────── 3. Aliases for the website ───────────── */

  /* Surfaces */
  --bg-color: var(--color-bg-surface);
  --bg-subtle: var(--gray-100);
  --bg-surface: var(--color-bg-surface);
  --bg-surface-hover: var(--gray-100);
  --bg-overlay: rgb(var(--paper-rgb) / 0.94);
  --border-color: var(--color-border-card);
  --border-subtle: var(--color-divider);
  --border-highlight: rgb(var(--ink-rgb) / 0.2);
  --border-ui: var(--color-border-input);
  --border-focus: var(--blue-500);
  --focus-ring: var(--blue-500);

  /* Text */
  --text-main: var(--color-text-primary);
  --text-muted: var(--color-text-secondary);
  --text-subtle: var(--color-text-secondary);
  --text-inverse: rgb(var(--paper-rgb));

  /* Brand */
  --primary: var(--blue-500);
  --on-primary: rgb(var(--paper-rgb));
  --primary-hover: var(--blue-600);
  --primary-text: var(--blue-700);
  --primary-subtle: rgb(var(--blue-rgb) / 0.08);
  --primary-surface: rgb(var(--blue-rgb) / 0.12);
  --primary-border: rgb(var(--blue-rgb) / 0.28);
  --provider-accent: var(--provider-700);
  --provider-hover: var(--provider-800);
  --provider-subtle: rgb(var(--amber-rgb) / 0.08);
  --provider-border: rgb(var(--amber-rgb) / 0.28);

  /* Status */
  --success: var(--green-600);
  --success-text: var(--green-700);
  --success-subtle: rgb(var(--green-rgb) / 0.08);
  --success-surface: rgb(var(--green-rgb) / 0.1);
  --success-border: rgb(var(--green-rgb) / 0.3);
  --warning: var(--amber-700);
  --warning-text: var(--amber-700);
  --warning-surface: rgb(var(--amber-rgb) / 0.1);
  --danger: var(--red-600);
  --on-danger: rgb(var(--paper-rgb));
  --danger-hover: var(--red-700);
  --danger-text: var(--red-700);
  --danger-subtle: rgb(var(--red-rgb) / 0.08);
  --danger-surface: rgb(var(--red-rgb) / 0.1);
  --danger-border: rgb(var(--red-rgb) / 0.3);
  --secondary: var(--gray-200);
  --secondary-hover: var(--gray-300);
  --card-bg: var(--bg-surface);
  --code-bg: var(--color-bg-code);
  --code-text: var(--color-text-primary);
  --code-header: var(--gray-200);

  /* Elevation */
  --shadow-subtle: var(--shadow-control);
  --shadow-flyout: var(--shadow-popover);
  --elev-0: none;
  --elev-1: var(--shadow-subtle);
  --elev-2: var(--shadow-card);
  --elev-3: var(--shadow-flyout);

  /* The font feature switch is inherited by everything. */
  font-feature-settings: var(--font-features);
  color-scheme: light;
}

/* Controls and their descendants restart font settings with the `font`
   shorthand, which would drop the stylistic set; this keeps it everywhere. */
*,
*::before,
*::after {
  font-feature-settings: var(--font-features) !important;
}

/* The SpiderWeb logomark. Use <i class="logomark"></i>; it takes the color of
   the text around it and is 16px unless a component sets a size. The file sits
   beside this stylesheet on every surface. */
.logomark {
  display: inline-block;
  flex: none;
  width: var(--size-icon);
  height: var(--size-icon);
  background-color: currentColor;
  -webkit-mask: url('logomark.svg') center / contain no-repeat;
  mask: url('logomark.svg') center / contain no-repeat;
}
