/* ============================================================================
 * @startup/tokens — FOUNDATION
 *
 * Theme-INDEPENDENT primitives: the raw colour palette and the numeric scales.
 * Nothing in this file changes between light and dark; everything that does
 * lives in `semantic.css` and is expressed in terms of what is defined here.
 *
 * This file is the SINGLE SOURCE OF TRUTH for the design system. It is read
 * three ways and must never be duplicated:
 *   - browsers        → imported as CSS (see `index.css`)
 *   - Tailwind        → parsed at build time by `theme.ts`
 *   - application JS  → the curated subset re-declared in `palette.ts`,
 *                       kept honest by `__tests__/tokens.test.ts`
 *
 * Naming
 *   --c-*   colour primitive (never theme-aware, never used directly in a
 *           component — go through a semantic token in `semantic.css`)
 *   --bt-*  BapTech page-runtime tokens authored by the AI page builder
 *           (defined by the builder's exporter, NOT here — see
 *           `apps/web/src/builder/core/export/spacingTokensCss.ts`)
 *   everything else — a numeric scale, named by its value
 *
 * Units
 *   Spacing, radii and font sizes are in `rem` so the whole UI respects the
 *   reader's browser font-size setting. At the default 16px root these are
 *   pixel-identical to the values the comments quote.
 * ========================================================================= */

:root {
  /* ==========================================================================
   * COLOUR — brand
   * ======================================================================= */

  /* Primary — BapTech brass. Taken from the brand's own site rather than
   * derived: `100`/`200`/`300` are landing.baptech.app's brass-400/500/600
   * exactly, so the product and the page that sells it are the same colour.
   *
   * The ramp runs lightest (50) to darkest (500) with no gaps, and every step
   * exists because a state needs it — there are no spare tones:
   *
   *   50   pale wash — a disabled fill on a LIGHT surface
   *   100  hover, and the lighter tone on a dark surface
   *   200  THE brand colour                       8.86:1 on --c-base-900
   *   300  pressed, and brand borders on a light surface
   *   400  the only brass dark enough to be TEXT on white — 4.71:1, where
   *        200 manages 2.25:1 and is unreadable
   *   500  a disabled fill on a DARK surface
   *
   * A brass surface takes DARK text, not white: --c-base-900 on 200 measures
   * 8.86:1, white on 200 only 2.37:1. See --text-on-brand in semantic.css. */
  --c-brand-50: #efe3c8;
  --c-brand-100: #dcc38d;
  --c-brand-200: #c8a96a;
  --c-brand-300: #a98c4f;
  --c-brand-400: #8a7038;
  --c-brand-500: #55482a;

  /* Secondary — steel. The family behind "accent": secondary buttons, the
   * emphasis that must not read as the primary action.
   *
   * It was teal, inherited from the reference. The brand has no second hue —
   * on the landing, secondary emphasis is carried by the mist neutrals and by
   * brass at low alpha, never by a competing colour. So this family is now
   * the mist ramp, and the name still fits: it is the SUBORDINATE brand
   * family, which is a role, not a hue.
   *
   * Steps mirror the brass ramp exactly, including `400` as the only step
   * dark enough to be text on white (8.14:1). */
  --c-brand-sub-50: #dfe2e7;
  --c-brand-sub-100: #9ba1ab;
  --c-brand-sub-200: #7d838d;
  --c-brand-sub-300: #5f6570;
  --c-brand-sub-400: #4a5058;
  --c-brand-sub-500: #2b2f36;

  /* ==========================================================================
   * COLOUR — base & neutrals
   * ======================================================================= */

  --c-base-white: #ffffff;
  --c-base-50: #f4f5f7; /* light-theme page background */
  --c-base-900: #08090b; /* dark-theme page background — the landing's ink-900 */
  --c-base-black: #000000;

  /* Overlay washes. Neutral-on-ink rather than the reference's blue-violet: a
   * tinted overlay is the fastest way to make a near-black theme look like two
   * different products on two different screens. */
  --c-base-gradient-1: linear-gradient(180deg, #14161b 0%, #0b0c0e 100%);
  --c-base-gradient-2: linear-gradient(180deg, #101216 0%, #08090b 68.75%);

  /* Neutral ramp, strictly monotonic light → dark. Every step is a real
   * surface or text tone in one of the two themes; there are no spare steps.
   *
   * 100–500 are the landing's mist scale and 700–900 its ink scale, so the
   * dark theme's page, surface and container planes are the same three greys
   * the marketing site uses (#08090b / #101216 / #14161b) rather than merely
   * similar ones.
   *
   * Measured, so it is not re-litigated: mist-100 on ink-900 is 16.68:1,
   * mist-300 7.66:1, mist-400 5.22:1. mist-500 is 3.40:1 and is therefore a
   * placeholder/disabled tone only — never body text on a dark surface. */
  --c-neutral-50: #f4f5f7;
  --c-neutral-100: #e9ebee;
  --c-neutral-200: #c3c7ce;
  --c-neutral-300: #9ba1ab;
  --c-neutral-400: #7d838d;
  --c-neutral-500: #5f6570;
  /* No landing step sits here. It is derived on the same hue and exists
   * because the dark theme needs a plane between the mist tones and the ink
   * ones — `--bg-container-secondary` and `--bg-element-quaternary` live at
   * this step and would otherwise jump from #5f6570 straight to #14161b. */
  --c-neutral-600: #21252b;
  --c-neutral-700: #14161b;
  --c-neutral-800: #101216;
  --c-neutral-900: #0b0c0e;

  /* ==========================================================================
   * COLOUR — accents
   * ======================================================================= */

  /* The signature warm sweep. Used for gradient buttons, the title rule and
   * the active-sidebar border. `-2` is the same sweep at 40% alpha, which is
   * how the disabled state of a gradient surface is expressed. */
  --c-accent-gradient: linear-gradient(90deg, #a98c4f 0%, #efe3c8 50%, #dcc38d 100%);
  --c-accent-gradient-2: linear-gradient(
    90deg,
    rgba(169, 140, 79, 0.4) 0%,
    rgba(239, 227, 200, 0.4) 50%,
    rgba(220, 195, 141, 0.4) 100%
  );

  --c-accent-danger-50: #f7b3bb;
  --c-accent-danger-100: #f06677;
  --c-accent-danger-200: #ea4b61;
  --c-accent-danger-300: #5a1226;

  --c-accent-success-200: #00df80;
  --c-accent-success-300: #16db65;

  /* --------------------------------------------------------------------------
   * Gradients
   *
   * Named by role. `accent` is the signature warm sweep above, exposed under a
   * second name so gradient call sites read consistently; `brand` is the solid
   * orange wash used on primary surfaces; `hero` is the page-top glow.
   * ----------------------------------------------------------------------- */
  --gradient-accent: var(--c-accent-gradient);
  --gradient-brand: linear-gradient(135deg, #c8a96a 0%, #dcc38d 100%);
  --gradient-hero: radial-gradient(
      ellipse 80% 60% at 50% 0%,
      rgba(200, 169, 106, 0.13) 0%,
      transparent 60%
    ),
    linear-gradient(180deg, #08090b 0%, #050608 100%);

  /* ==========================================================================
   * COLOUR — informational hues
   *
   * Each hue ships two tones. `100` is tuned to sit on a LIGHT surface,
   * `200` on a DARK one; `semantic.css` picks the right one per theme so
   * component code never has to. Do not reach for these directly.
   * ======================================================================= */
  --c-info-green-100: #77dd77;
  --c-info-red-100: #ff718b;
  --c-info-yellow-100: #f8c700;
  --c-info-blue-100: #5f9fff;
  --c-info-cyan-100: #29c6cd;
  --c-info-teal-100: #7ecfc0;
  --c-info-violet-100: #a77afe;
  --c-info-brown-100: #da9461;
  --c-info-orange-100: #ff8364;

  --c-info-green-200: #22c55e;
  --c-info-red-200: #f7374f;
  --c-info-yellow-200: #ffcc00;
  --c-info-blue-200: #0a84ff;
  --c-info-cyan-200: #00b4d8;
  --c-info-teal-200: #52b290;
  --c-info-violet-200: #ba29e0;
  --c-info-brown-200: #a47148;
  --c-info-orange-200: #fb8500;

  /* A third tone, for the one consumer that cannot pick per theme: a chart
   * series is a single literal handed to a renderer that never re-reads it,
   * so it has to clear 3:1 on BOTH the ink page and the paper one. Green is
   * the hue where neither existing tone manages that (`200` is 8.74:1 on ink
   * but 2.09:1 on paper), and a chart with no green is a chart that cannot
   * say "up". Measured: 4.95:1 on --c-base-900, 3.69:1 on --c-base-50. */
  --c-info-green-300: #358f57;

  /* ==========================================================================
   * COLOUR — label palette
   *
   * The user-assignable colours offered when tagging a record. Ordered, stable
   * and persisted BY INDEX, so entries may be re-toned but never re-ordered or
   * removed without a data migration.
   * ======================================================================= */
  --c-label-1-mint-green: #7de6a0;
  --c-label-2-soft-sage: #a3dc9a;
  --c-label-3-pale-mint: #c9e9d2;
  --c-label-4-ice-blue: #aae3e2;
  --c-label-5-sky-blue: #7bd3ea;
  --c-label-6-pastel-yellow: #fada7a;
  --c-label-7-cream-beige: #f7dcb9;
  --c-label-8-lavender-light: #cdc1ff;
  --c-label-9-pink-blossom: #fcc2fc;
  --c-label-10-dusty-rose: #ef9595;
  --c-label-11-charcoal-gray: #535962;
  --c-label-12-soft-stone: #deded1;
  --c-label-13-pure-white: #ffffff;

  /* ==========================================================================
   * COLOUR — links & utility
   * ======================================================================= */
  --c-link-50: #5ca3ff;
  --c-link-100: #2d88ff;
  --c-link-200: #0066ff;

  --c-utility-500: #6e6f76;
  --c-utility-600: #303746;

  /* ==========================================================================
   * TYPOGRAPHY
   * ======================================================================= */

  /* Three real families, the same three the landing loads.
   *
   * The family this replaced could not render Vietnamese: 15 of the 18
   * Vietnamese-only codepoints probed were absent from its cmap, so in a
   * Vietnamese-first product every accented word fell back to a system font
   * mid-sentence. All three below ship the `vietnamese` subset. */
  --font-family-primary: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    Roboto, 'Helvetica Neue', Arial, sans-serif;
  /* Display is a genuinely different face, not an alias: headings are Archivo,
   * set tight, and that is what gives the brand its voice. */
  --font-family-display: 'Archivo', 'Segoe UI', ui-sans-serif, sans-serif;
  --font-family-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --font-size-base: 1rem; /* 16px */
  --font-size-8: 0.5rem; /* 8px */
  --font-size-10: 0.625rem; /* 10px */
  --font-size-11: 0.6875rem; /* 11px */
  --font-size-12: 0.75rem; /* 12px */
  --font-size-13: 0.8125rem; /* 13px */
  --font-size-14: 0.875rem; /* 14px */
  --font-size-16: 1rem; /* 16px */
  --font-size-18: 1.125rem; /* 18px */
  --font-size-20: 1.25rem; /* 20px */
  --font-size-24: 1.5rem; /* 24px */
  --font-size-30: 1.875rem; /* 30px */
  --font-size-32: 2rem; /* 32px */
  --font-size-36: 2.25rem; /* 36px */
  --font-size-40: 2.5rem; /* 40px */
  --font-size-48: 3rem; /* 48px */
  --font-size-56: 3.5rem; /* 56px */
  --font-size-64: 4rem; /* 64px */

  /* Only weights with a real cut in the shipped families are listed — see
   * `fonts.css`, and the test that compares the two.
   *
   * `medium` is 500 again. It was pinned to 600 because the previous family
   * had no 500 cut, which collapsed `medium` and `semibold` onto one weight
   * and is a large part of why the UI read flat. Plus Jakarta Sans is a
   * variable face covering 200–800, so 500 is now a real instance.
   *
   * 100 and 900 are gone: the body family stops at 200 and 800, and a token
   * resolving to a weight the font cannot produce asks the browser to
   * synthesise one, which looks different on every platform. */
  --font-weight-hairline: 200;
  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;

  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;

  --letter-spacing-tighter: -0.035em;
  --letter-spacing-tight: -0.025em;
  --letter-spacing-snug: -0.01em;
  --letter-spacing-normal: 0em;
  --letter-spacing-wide: 0.025em;
  --letter-spacing-wider: 0.05em;
  --letter-spacing-widest: 0.1em;
  /* Reserved for all-caps eyebrow labels, which need far more tracking than
   * the general scale provides. 0.24em is the landing's value. */
  --letter-spacing-eyebrow: 0.24em;
  /* Display type is set tight. This is the landing's heading tracking, and the
   * single most recognisable thing about how the brand sets a headline. */
  --letter-spacing-display: -0.026em;

  /* ==========================================================================
   * SPACING
   *
   * Named by pixel value at the default root size. Dense steps exist below
   * 32px because that is where component internals live; above it the scale
   * deliberately thins out.
   * ======================================================================= */
  --spacing-0: 0;
  --spacing-2: 0.125rem; /* 2px */
  --spacing-4: 0.25rem; /* 4px */
  --spacing-6: 0.375rem; /* 6px */
  --spacing-8: 0.5rem; /* 8px */
  --spacing-10: 0.625rem; /* 10px */
  --spacing-12: 0.75rem; /* 12px */
  --spacing-14: 0.875rem; /* 14px */
  --spacing-16: 1rem; /* 16px */
  --spacing-18: 1.125rem; /* 18px */
  --spacing-20: 1.25rem; /* 20px */
  --spacing-22: 1.375rem; /* 22px */
  --spacing-24: 1.5rem; /* 24px */
  --spacing-26: 1.625rem; /* 26px */
  --spacing-28: 1.75rem; /* 28px */
  --spacing-30: 1.875rem; /* 30px */
  --spacing-32: 2rem; /* 32px */
  --spacing-36: 2.25rem; /* 36px */
  --spacing-40: 2.5rem; /* 40px */
  --spacing-44: 2.75rem; /* 44px */
  --spacing-48: 3rem; /* 48px */
  --spacing-50: 3.125rem; /* 50px */
  --spacing-56: 3.5rem; /* 56px */
  --spacing-60: 3.75rem; /* 60px */
  --spacing-64: 4rem; /* 64px */
  --spacing-80: 5rem; /* 80px */
  --spacing-96: 6rem; /* 96px */
  --spacing-128: 8rem; /* 128px */

  /* ==========================================================================
   * BORDERS
   * ======================================================================= */
  --border-width-none: 0;
  --border-width-thin: 1px;
  --border-width-default: 1.5px; /* inputs, radios, checkboxes */
  --border-width-medium: 2px;
  --border-width-thick: 2.5px;
  --border-width-bold: 3px;

  --border-radius-none: 0;
  --border-radius-4: 0.25rem;
  --border-radius-6: 0.375rem;
  --border-radius-8: 0.5rem;
  --border-radius-10: 0.625rem;
  --border-radius-12: 0.75rem;
  --border-radius-14: 0.875rem;
  --border-radius-16: 1rem;
  --border-radius-18: 1.125rem;
  --border-radius-20: 1.25rem;
  --border-radius-22: 1.375rem;
  --border-radius-24: 1.5rem;
  --border-radius-28: 1.75rem;
  --border-radius-32: 2rem;
  --border-radius-full: 9999px;

  /* The three radii the brand actually uses, named by what they wrap. Aliases
   * of the numeric steps above, so there is still one scale — but a component
   * that reaches for `--radius-field` cannot drift 2px from every other field
   * the way `--border-radius-12` sitting next to `--border-radius-14` invites. */
  --radius-field: var(--border-radius-12); /* inputs, buttons, chips */
  --radius-core: var(--border-radius-18); /* cards, panels, menus */
  --radius-plate: var(--border-radius-22); /* the largest surfaces */

  /* ==========================================================================
   * ELEVATION
   *
   * Neutral-black shadows only. Theme-aware elevation (cards, modals,
   * dropdowns, focus rings) is in `semantic.css`.
   * ======================================================================= */
  --shadow-xs: 0 1px 1px 0 rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);

  /* ==========================================================================
   * MOTION
   *
   * Duration and easing are separate primitives so a transition can mix them
   * freely (`transform var(--dur-slow) var(--ease-out)`). The combined
   * `--transition-*` shorthands are kept for the common single-property case.
   * ======================================================================= */
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 320ms;

  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-in: cubic-bezier(0.6, 0, 0.8, 0.3);
  --ease-snap: cubic-bezier(0.3, 1.4, 0.5, 1);
  /* The landing's easing for anything that slides or lifts into place. Very
   * fast out of the gate and a long settle — it is what makes the brand's
   * motion read as weighty rather than bouncy. */
  --ease-plate: cubic-bezier(0.32, 0.72, 0, 1);

  --transition-fast: var(--dur-fast) var(--ease-out);
  --transition-normal: var(--dur-base) var(--ease-out);
  --transition-slow: var(--dur-slow) var(--ease-out);

  /* ==========================================================================
   * SCROLLBARS
   * ======================================================================= */
  --scrollbar-width: 6px;
  --scrollbar-hover-width: 8px;
  --scrollbar-radius: 9999px;

  /* ==========================================================================
   * STACKING
   *
   * Every layer that can overlap another is enumerated here. A component that
   * needs to sit above its siblings uses a local, relative z-index; only
   * things that escape their stacking context appear on this list.
   * ======================================================================= */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;

  /* ==========================================================================
   * LAYOUT
   * ======================================================================= */
  --breakpoint-xxs: 320px;
  --breakpoint-xs: 480px;
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;

  --container-max: 1280px;
  --container-px: var(--spacing-24);

  /* ==========================================================================
   * COMPONENT SIZING
   *
   * Shared control metrics. A button and an input of the same size must line
   * up on a single row, so the two scales are defined together and are equal
   * by construction.
   * ======================================================================= */
  --control-height-sm: 2rem; /* 32px */
  --control-height-md: 2.75rem; /* 44px — meets the 44px touch-target floor */
  --control-height-lg: 3rem; /* 48px */

  --button-height-sm: var(--control-height-sm);
  --button-height-md: var(--control-height-md);
  --button-height-lg: var(--control-height-lg);

  --input-height-sm: var(--control-height-sm);
  --input-height-md: var(--control-height-md);
  --input-height-lg: var(--control-height-lg);

  --card-padding-sm: var(--spacing-16);
  --card-padding-md: var(--spacing-24);
  --card-padding-lg: var(--spacing-32);
}

/* ============================================================================
 * REDUCED MOTION
 *
 * Collapsing the duration primitives disables every transition expressed in
 * terms of them, including ones written by hand as
 * `opacity var(--dur-base) var(--ease-out)`.
 * ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0s;
    --dur-base: 0s;
    --dur-slow: 0s;
  }
}
