/* =============================================================================
   HF Hub — Design Tokens
   -----------------------------------------------------------------------------
   The single source of truth for EVERY colour and dimension in the application.
   No other file in this project declares a hex value. Ever.

   Three layers:
     1. Raw brand palette      — the physical brand colours. NEVER referenced
                                  by a component. Only the semantic layer may
                                  reach in here.
     2. Ramps & functional     — the warm neutral ramp, the functional colours
                                  (light + dark variants), and the categorical
                                  chart colours. Also never touched directly by
                                  components.
     3. Semantic layer         — the ONLY layer a component is ever allowed to
                                  reference. Defined twice: once for light, once
                                  for dark. Toggle [data-theme] to re-map.

   Non-colour scales (spacing, radii, elevation, motion, type stacks) live in
   the base :root block because they do not change between themes.
============================================================================= */

:root {
  /* ---------------------------------------------------------------------------
     LAYER 1 — RAW BRAND PALETTE
     Do not reference these from a component. Semantic layer only.
  --------------------------------------------------------------------------- */
  --brand-aubergine: #231E25;
  --brand-caramel:   #B6815D;
  --brand-taupe:     #D8B597;
  --brand-blush:     #ECD9CA;

  /* ---------------------------------------------------------------------------
     LAYER 2 — NEUTRAL RAMP
     Derived from the aubergine hue so the greys read warm, never cold slate.
  --------------------------------------------------------------------------- */
  --neutral-0:   #FFFFFF;
  --neutral-25:  #FBF9F8;
  --neutral-50:  #F5F2F0;
  --neutral-100: #EDE8E5;
  --neutral-200: #DFD8D4;
  --neutral-300: #C7BEBA;
  --neutral-400: #A79C9A;
  --neutral-500: #847A7A;
  --neutral-600: #635B5E;
  --neutral-700: #463F44;
  --neutral-800: #312A31;
  --neutral-900: #231E25;

  /* ---------------------------------------------------------------------------
     LAYER 2 — FUNCTIONAL COLOURS
     Each ships a light and a dark variant, because a colour that works on white
     fails on aubergine. The semantic layer picks the correct variant per theme.
  --------------------------------------------------------------------------- */
  /* ⚠ THE THREE LIGHT VALUES WERE DARKENED SO .badge CLEARS AA, AND THEY WERE DERIVED, NOT PICKED.
     .badge paints text in the functional colour on a 12% tint of that same colour mixed into
     --surface-page, so the colour is on both sides of its own contrast ratio. Measured on the previous
     values the light badges came out at positive 4.24, warning 4.21, info 4.08 — all under the 4.5 that
     applies, because .badge is --type-micro (0.625rem / 10px), below the large-text threshold in both
     dimensions. Each source was walked toward black, RECOMPUTING THE FILL AT EVERY STEP because the fill
     moves with it, until the badge cleared 4.6:1 (headroom, not the line):
        positive #5F7350 → #596C4B   6% toward black   badge 4.24 → 4.64
        warning  #8A6819 → #826218   6%                badge 4.21 → 4.61
        info     #5F7285 → #57697A   8%                badge 4.08 → 4.61
     --func-negative-light is UNCHANGED: its badge already measured 4.81:1 and the walk returned it
     untouched. All four DARK values are unchanged for the same reason — dark badges measure 5.03 to 6.11.

     These are status colours used well beyond badges (positive 50 uses, warning 36, negative 68, info 3),
     overwhelmingly as `color:` on light grounds, where darkening only improves the ratio. The frozen
     functional TINT tokens below (--surface-positive and friends) were derived from the OLD values and
     are literals, so they have not moved; they carry --text-primary, not the functional colour, so the
     ~1% drift changes nothing measurable. */
  --func-positive-light: #596C4B;
  --func-positive-dark:  #97AD86;
  --func-warning-light:  #826218;
  --func-warning-dark:   #D4AC5A;
  --func-negative-light: #A34733;
  --func-negative-dark:  #D98A72;
  --func-info-light:     #57697A;
  --func-info-dark:      #93A5B5;

  /* ---------------------------------------------------------------------------
     LAYER 2 — CATEGORICAL CHART COLOURS (in order 1..7)
  --------------------------------------------------------------------------- */
  --chart-1: #B6815D;
  --chart-2: #4A3F4A;
  --chart-3: #6E8062;
  --chart-4: #5F7285;
  --chart-5: #D8B597;
  --chart-6: #A8862E;
  --chart-7: #8A6B7A;

  /* ---------------------------------------------------------------------------
     SPACING — four pixel base.
     HARD RULE: nothing in this project uses an off-scale value. If a gap isn't
     one of these nine steps, the design is wrong, not the scale.
  --------------------------------------------------------------------------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;

  /* ---------------------------------------------------------------------------
     CONTROL SIZING — ergonomic constants for interactive controls.
     These sit alongside the spacing scale but are NOT part of it: a control
     height is not a multiple of a spacing unit. They are deliberately literal so
     that tuning the spacing scale can never silently resize a button, field or
     toggle. Do not derive these from --space-*, and do not use --space-* for a
     control's own height/knob dimensions — use these instead.
  --------------------------------------------------------------------------- */
  --control-h-sm:     28px;
  --control-h-md:     36px;
  --control-h-lg:     44px;
  --control-pad-x-sm: 12px;
  --control-pad-x-md: 16px;
  --control-pad-x-lg: 24px;
  --badge-pad-y:      2px;
  --badge-pad-x:      8px;
  --toggle-w:         36px;
  --toggle-h:         20px;
  --toggle-knob:      16px;
  --choice-size:      16px;
  --spark-w:          64px;
  --spark-h:          24px;
  --row-h-compact:     32px;
  --row-h-comfortable: 40px;
  --row-h-spacious:    52px;
  --metric-value-md:   2rem;    /* stepped metric value — medium-length values */
  --metric-value-lg:   1.5rem;  /* stepped metric value — long values (below display-2) */

  /* ---------------------------------------------------------------------------
     DRILL-DOWN PANEL WIDTH — M349. A table drill's panel is as wide as its table's
     one-line width, never narrower than --drilldown-w (the panel's width before M349)
     and never wider than --drilldown-w-max; past that, and only past that, its body
     scrolls sideways. --drilldown-clip-w is where a free-text cell (an address, an
     opportunity name) stops and ends in an ellipsis, the full text in its tooltip, so
     one long value cannot push every row past the maximum. Desktop only — below the
     900px drawer breakpoint the panel is full width, as it always was.
  --------------------------------------------------------------------------- */
  --drilldown-w:      880px;
  --drilldown-w-max:  92vw;
  --drilldown-clip-w: 36ch;

  /* ---------------------------------------------------------------------------
     RADII
  --------------------------------------------------------------------------- */
  --radius-none: 0;
  --radius-sm:   2px;
  --radius-md:   4px;
  --radius-lg:   8px;
  --radius-pill: 999px;

  /* ---------------------------------------------------------------------------
     ELEVATION — three and only three. No other shadows exist.
  --------------------------------------------------------------------------- */
  --shadow-none:    none;
  --shadow-popover: 0 4px 16px rgba(35, 30, 37, 0.10);
  --shadow-modal:   0 16px 48px rgba(35, 30, 37, 0.18);

  /* ---------------------------------------------------------------------------
     MOTION — durations plus one shared easing curve the whole system uses.
  --------------------------------------------------------------------------- */
  --motion-micro:    120ms;
  --motion-standard: 200ms;
  --motion-entrance: 320ms;
  --motion-data:     600ms;
  /* Primary-mark entrance — the deliberate settle of a page's hero mark (the login
     logo, the investor-pack hero). Slower and later than the standard entrance so
     the canvas fully establishes before the mark arrives. Named by role, not
     length, so they survive retuning. */
  --motion-mark-settle: 900ms;
  --motion-mark-delay:  300ms;
  /* Ambient loops — continuous background animation such as skeleton shimmer and
     indeterminate progress. Deliberately its own token, distinct from the feedback
     durations above (which time discrete state changes): a slow endless loop is not
     a multiple of a UI-feedback duration, and coupling them would let retuning one
     silently retune the other. */
  --motion-ambient: 1500ms;
  /* Data rendering itself onto a chart — the draw-on entrance (line stroke, bar
     column grow, donut sweep and centre count-up). A calm, deliberate span, longer
     than any feedback duration on purpose: those time discrete interface state
     changes (a hover, an accordion), whereas this is data arriving. All chart types
     share it so a page of several charts resolves as one gesture, not four. */
  --motion-draw: 3000ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  /* Long-form data animation (the chart draw-on). A true ease-out — quick off the
     mark, then a long, even deceleration that settles into place. The shared --ease
     above is tuned for short interface transitions; over a span this long it reaches
     its end early and reads as halting rather than arriving. One curve, shared by
     all four chart draw-on types. */
  --ease-data: cubic-bezier(0.215, 0.61, 0.355, 1);

  /* ---------------------------------------------------------------------------
     TYPE STACKS
  --------------------------------------------------------------------------- */
  --font-display: "presti-display", Georgia, serif;
  /* Interim measure: the body stack stays on Helvetica system fallbacks until a
     web licence for Helvetica is resolved. Swap the first family when it lands. */
  --font-body: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
}

/* =============================================================================
   LAYER 3 — SEMANTIC (LIGHT)
   The only layer components reference. :root doubles as the light theme so the
   app is correct before any [data-theme] is set.
============================================================================= */
:root,
[data-theme="light"] {
  /* Surfaces */
  --surface-page:     var(--neutral-25);
  --surface-raised:   var(--neutral-0);
  --surface-sunken:   var(--neutral-50);
  --surface-inverse:  var(--brand-aubergine);
  --surface-hover:    var(--neutral-100);
  --surface-selected: rgba(182, 129, 93, 0.10);

  /* Text */
  --text-primary:   var(--brand-aubergine);
  --text-secondary: var(--neutral-500);
  --text-tertiary:  var(--neutral-400);
  --text-inverse:   var(--brand-blush);
  --text-accent:    #8F6244; /* caramel darkened to pass AA on a light surface */

  /* Borders */
  --border-subtle:  var(--neutral-100);
  --border-default: var(--neutral-200);
  --border-strong:  var(--neutral-300);
  --border-accent:  var(--brand-caramel);

  /* Accent */
  --accent:          var(--brand-caramel);
  --accent-hover:    #A2704E;
  --accent-contrast: #FFFFFF;
  --focus-ring:      var(--brand-caramel);

  /* Disabled — a ground, an edge and a text colour for a control that is unavailable.
     Named because there was no way to say "disabled" in the semantic layer at all: every disabled control
     in the app expressed it as opacity: 0.45, which cannot be made legible (see .btn:disabled).

     ⚠ --text-disabled IS A NEW VALUE; the other two alias existing tokens and are named only so the
     treatment reads as one concept. --text-tertiary was the obvious candidate and measures 2.40:1 on this
     ground — better than anything the buttons had, still short of AA. This value was DERIVED, not chosen:
     --text-tertiary walked toward black until it cleared 4.5:1 against --surface-sunken, stopping at 4.60
     so rounding could not drop it back under. All three channels were rounded by one shared delta to keep
     the palette's warm neutral rather than drifting grey.
        #746C6B on #F5F2F0 = 4.60:1 — passes AA body (4.5) and AA large (3.0) */
  --text-disabled:    #746C6B;
  --surface-disabled: var(--surface-sunken);
  --border-disabled:  var(--border-default);

  /* Quiet badge text — the grey .badge states, and the only one of them that is NOT a functional colour.
     A badge-scoped token rather than a shift of --text-secondary, deliberately: --text-secondary has 324
     consumers across 30 files, 312 of them plain `color:`, so darkening it to fix a pill would restyle
     body copy across the whole app. --text-tertiary (83 consumers) is the same objection. This value is
     answerable only to badges.

     DERIVED against BOTH grounds a quiet badge uses, because one value has to satisfy them or it is two
     tokens: the SOLID --surface-hover fill (.badge--neutral / --dev / --auto / --stale) and the 12% tint
     of itself (.badge--dot's default, .ref-status--lost). Walked from --text-secondary toward black:
        #6E6565  on the solid fill 4.65   on its own tint 4.60   (17% toward black)
        and on the bare surfaces .badge--dot sits on: page 5.39 · raised 5.66 · sunken 5.08 */
  --badge-text-quiet:    #6E6565;
  /* The quiet fill, named and OPAQUE. It was --surface-hover, which is opaque in this theme but a 6% wash
     in dark — and a translucent fill takes its real value from whatever is behind it, so the same badge
     measured 4.73 on the page and 4.04 on a raised card. That is the disabled-button lesson again: a
     value that composites with its backdrop cannot be reasoned about, only measured per backdrop. Fixing
     it opaque makes the badge identical on every surface. Light keeps the value --surface-hover already
     had, so nothing changes here; dark takes what the wash painted over the page. */
  --badge-surface-quiet: #EDE8E5;

  /* Functional — light variants map onto the semantic names */
  --positive: var(--func-positive-light);
  --warning:  var(--func-warning-light);
  --negative: var(--func-negative-light);
  --info:     var(--func-info-light);

  /* Functional TINTS — a fill and its border, per state.
     A banner needs a ground and an edge, and before these every page invented its own: 158 hardcoded
     tinted declarations across 16 files, using 63 distinct hex values for what are three states.

     ⚠ LITERALS, NOT color-mix(). components.css derives its tints live — .badge is
     color-mix(in srgb, var(--badge-color) 12%, var(--surface-page)) — and that is right for a component,
     which fails visibly if the function is unsupported. It is wrong for the TOKEN layer: an unsupported
     color-mix in a custom property resolves to nothing, and a background that resolves to nothing is
     transparent, not broken-looking. Every other token in this file is a literal; a derived one would be
     the exception that fails silently. The values below were DERIVED with the same arithmetic the
     components use, then frozen:
        fill   = functional colour at 12% over --surface-page    (the .badge strength)
        border = functional colour at 45% over --border-default  (the .hf-group--warning strength)

     ⚠ TEXT ON THESE FILLS IS --text-primary, NOT THE STATE'S OWN COLOUR. Measured on these exact values:
        --text-primary  on positive 13.40:1 · warning 13.39:1 · negative 13.15:1   — all pass AA
        the state colour on its own fill:  4.24:1 · 4.22:1 · 4.81:1                — two of three FAIL
     The functional colour is for the BORDER, and for an icon or a badge where it is not carrying prose.
     A tinted banner carries a sentence, and a sentence needs 4.5:1.

     THREE STATES, ONE STRENGTH, deliberately. --info has no consumer, and a second (stronger) pair would
     make every caller choose between two with no guidance. Both are additive later; neither is removable. */
  --surface-positive: #E8E9E4;
  --surface-warning:  #EDE8DD;
  --surface-negative: #F0E4E0;
  --border-positive:  #A5AB99;
  --border-warning:   #B9A680;
  --border-negative:  #C4978C;
}

/* =============================================================================
   LAYER 3 — SEMANTIC (DARK)
============================================================================= */
[data-theme="dark"] {
  /* Surfaces */
  --surface-page:     var(--neutral-900);
  --surface-raised:   var(--neutral-800);
  --surface-sunken:   #1B171C;
  --surface-inverse:  var(--neutral-25);
  --surface-hover:    rgba(236, 217, 202, 0.06);
  --surface-selected: rgba(182, 129, 93, 0.16);

  /* Text */
  --text-primary:   var(--brand-blush);
  --text-secondary: #A1928C;
  --text-tertiary:  #7A6E70;
  --text-inverse:   var(--brand-aubergine);
  --text-accent:    var(--brand-taupe);

  /* Borders */
  --border-subtle:  rgba(236, 217, 202, 0.08);
  --border-default: rgba(236, 217, 202, 0.14);
  --border-strong:  rgba(236, 217, 202, 0.24);
  --border-accent:  var(--brand-caramel);

  /* Accent */
  --accent:          var(--brand-taupe);
  --accent-hover:    var(--brand-blush);
  --accent-contrast: var(--brand-aubergine);
  --focus-ring:      var(--brand-taupe);

  /* Disabled — dark. Derived the same way and separately: --text-tertiary (#7A6E70, 3.62:1 here) walked
     toward this theme's --text-primary until it cleared 4.5:1 against the dark --surface-sunken.
        #8C7F7E on #1B171C = 4.60:1 — passes AA body and AA large

     ⚠ THE LIGHT VALUE WOULD FAIL HERE AND VICE VERSA, which is why this is derived per theme rather than
     shared. Swapped, each measures 3.46:1 against the other theme's ground — above AA large, below AA
     body, so a single shared value would quietly land the whole disabled vocabulary one tier short. */
  --text-disabled:    #8C7F7E;
  --surface-disabled: var(--surface-sunken);
  --border-disabled:  var(--border-default);

  /* Quiet badge text — dark. Derived separately against this theme's grounds; the dark --surface-hover is
     an rgba() wash, so it was composited over the page before being used as a ground rather than measured
     as if opaque. Barely moves, because the dark greys were already close:
        #A2938D  on the solid fill 4.79   on its own tint 4.60   (1% toward white)
        bare surfaces: page 5.53 · raised 4.71 · sunken 5.98 */
  --badge-text-quiet:    #A2938D;
  /* The wash --surface-hover painted over --surface-page, frozen opaque. #A2938D on it measures 4.80:1,
     and now measures that on every surface rather than only over the page. */
  --badge-surface-quiet: #2F292F;

  /* Functional — dark variants map onto the semantic names */
  --positive: var(--func-positive-dark);
  --warning:  var(--func-warning-dark);
  --negative: var(--func-negative-dark);
  --info:     var(--func-info-dark);

  /* Functional TINTS — dark. Same three states, same one strength; see the light block for why these are
     literals and why text on them is --text-primary.

     ⚠ BOTH VALUES MIX INTO THE PAGE HERE, not into --border-default as the light pair does. The dark
     --border-default is rgba(236, 217, 202, 0.14) — an alpha value, so there is nothing opaque to mix a
     border against, and mixing into a translucent colour yields a translucent result that would show the
     fill through its own edge. Mixing both into --surface-page keeps the pair opaque and coherent:
        fill = functional-dark at 12% over --surface-page · border = the same at 30%

     ⚠ A TINT INVERTS ON A DARK GROUND. In light, the fill is the functional colour lightened toward paper;
     here it is the DARK PAGE lifted toward the functional colour, which is why the hexes look like warm
     near-blacks rather than pastels. Reusing the light values here would produce three pale blocks on an
     aubergine page — the exact failure the LAYER 2 comment warns about.
        --text-primary on these fills: positive 9.70:1 · warning 9.53:1 · negative 9.84:1 — all pass AA */
  --surface-positive: #312F31;
  --surface-warning:  #382F2B;
  --surface-negative: #392B2E;
  --border-positive:  #464942;
  --border-warning:   #584935;
  --border-negative:  #5A3E3C;
}
