/* ===========================================================================
   Shared UI foundations — Astra Labs
   ---------------------------------------------------------------------------
   One small token + component layer so the marketing landing page and the
   three analytical workspaces read as a single application.

   Rules for this file, deliberately:

   * TOKENS ONLY for colour.  Pages alias their own variable names onto these
     (see the page roots); nothing here restyles a chart series, a trade
     outcome, or a quality tier.  Brand identity hues are separate tokens from
     the semantic data palette on purpose — the dashboard's violet used to
     borrow the chart-data purple, which made a navigation affordance look
     like a data reading.
   * NO keyframes, NO transitions, NO animation overrides.  Every animation
     under Visualizer/static/** is hand-tuned and protected; this layer is
     inert with respect to motion. Exception: html.trl-theme-vt rules only
     disable the browser's default cross-fade for the theme reveal; they
     declare no motion of their own.
   * Prefixed classes (`trl-*`) only, so nothing here can accidentally win a
     cascade fight with a page's own component styles.
   ======================================================================== */

/* ═══════════════════════════ TOKENS ═══════════════════════════ */

:root {
    /* Neutral ground / surfaces (dark = instrument, light = mineral paper) */
    --trl-ground: #0b0e16;
    --trl-page: #0f121b;
    --trl-panel: #151b27;
    --trl-raised: #1d2533;
    --trl-hover: #253145;
    --trl-border: #354156;
    --trl-border-soft: #242d3e;
    --trl-text: #e2e7f0;
    --trl-secondary: #a0aabd;
    --trl-dim: #8592a8;

    /* Chart + overlay surfaces */
    --trl-chart: #151b27;
    --trl-grid: #202a3a;
    --trl-overlay: rgba(15, 18, 27, 0.66);
    --trl-shadow: 0 18px 44px rgba(0, 0, 0, 0.45);

    /* Chart hover cards.  Both workspaces float one over the plot, so the
       surface has to follow the theme or the light palette ends up with
       dark ink on a dark card. */
    --trl-tooltip-bg: rgba(19, 23, 34, 0.82);
    --trl-tooltip-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);

    /* Workspace identity.  Distinct from the financial/model data palette. */
    --trl-dashboard: #a855f7;
    --trl-forecast: #2962ff;
    --trl-trading: #ff6d00;
    --trl-dashboard-text: #bb87f6;
    --trl-forecast-text: #7198ff;
    --trl-trading-text: #ff974c;
    --trl-focus: #7198ff;
    /* Ink for label text on the orange identity fill.  Chosen so it clears
       the AA floor against BOTH the dark-theme orange (#ff6d00 -> 6.6:1) and
       the deeper light-theme one (#d95a08 -> 4.8:1); white manages only
       2.8:1 and 3.9:1 respectively. */
    --trl-on-orange: #0f121b;

    /* Launch loader.  Kept as a token so the pre-paint cover, the flood
       discs, and the zoom stage's background rect cannot drift apart — they
       are three separate code paths that must agree to the byte. */
    --trl-launch-bg: #101c36;
    --trl-launch-rgb: 16, 28, 54;
    --trl-launch-copy: #c2cbf2;
    --trl-radar-disc: #2a1a0a;

    /* Geometry */
    --trl-radius-control: 6px;
    --trl-radius-action: 8px;
    --trl-radius-card: 10px;
    --trl-radius-dialog: 14px;

    /* Type */
    --trl-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --trl-mono: 'JetBrains Mono', 'Consolas', monospace;
    --trl-micro-size: 10px;
    --trl-micro-leading: 1.35;
    --trl-micro-tracking: .10em;
    --trl-ease-out: cubic-bezier(.22, 1, .36, 1);
    --trl-ease-in-out: cubic-bezier(.65, 0, .35, 1);
    --trl-ease-spring: linear(0, .26 8%, .78 19%, 1.06 29%, 1.09 35%, 1.03 47%, .99 61%, 1);
    --trl-dur-fast: 120ms;
    --trl-dur: 200ms;
    --trl-dur-slow: 360ms;
    --trl-wash: rgba(255, 255, 255, .045);
    --trl-wash-strong: rgba(255, 255, 255, .08);
    --trl-shadow-sm: 0 2px 8px rgba(0, 0, 0, .28);
    --trl-shadow-md: 0 8px 24px rgba(0, 0, 0, .36);
}

html[data-theme='light'] {
    --trl-ground: #eeefec;
    --trl-page: #f4f3ef;
    --trl-panel: #ffffff;
    --trl-raised: #ffffff;
    --trl-hover: #e6eaf0;
    --trl-border: #c3cad4;
    --trl-border-soft: #dce0e5;
    --trl-text: #1b2230;
    --trl-secondary: #596576;
    --trl-dim: #5f6a79;

    --trl-chart: #ffffff;
    --trl-grid: #edf0f3;
    --trl-overlay: rgba(244, 243, 239, 0.75);
    --trl-shadow: 0 18px 44px rgba(30, 35, 60, 0.18);

    --trl-tooltip-bg: rgba(255, 255, 255, 0.94);
    --trl-tooltip-shadow: 0 6px 24px rgba(30, 35, 60, 0.18);

    /* Accents darken on paper so they keep contrast against a light ground. */
    --trl-dashboard-text: #7132b1;
    --trl-forecast-text: #214bb8;
    --trl-trading-text: #934000;
    --trl-focus: #214bb8;

    --trl-launch-bg: #e9edf6;
    --trl-launch-rgb: 233, 237, 246;
    --trl-launch-copy: #435575;
    --trl-radar-disc: #fff4e8;
    --trl-wash: rgba(20, 24, 40, .045);
    --trl-wash-strong: rgba(20, 24, 40, .08);
    --trl-shadow-sm: 0 2px 8px rgba(30, 35, 60, .10);
    --trl-shadow-md: 0 8px 24px rgba(30, 35, 60, .14);
}

.trl-num { font-variant-numeric: tabular-nums; }

/* Scope the theme reveal so app-to-app navigation keeps its cross-fade. */
html.trl-theme-vt::view-transition-old(root),
html.trl-theme-vt::view-transition-new(root),
html.trl-theme-vt::view-transition-old(trl-theme-icon),
html.trl-theme-vt::view-transition-new(trl-theme-icon) {
    animation: none;
    mix-blend-mode: normal;
}
html.trl-theme-vt #theme-toggle svg,
html.trl-theme-vt #themeToggle svg {
    view-transition-name: trl-theme-icon;
}

/* ═══════════════════ ESSENTIAL MICRO-LABEL FLOOR ═══════════════════
   These carry meaning the reader must be able to act on: what a number is,
   which tier a card describes, what a workspace is for.  Decorative badges,
   chips and SVG annotations are deliberately NOT in this list — they are
   meant to sit back and their compactness is part of the composition. */

:root :is(.kicker,
.eyebrow,
.portal-tag,
.pricing-index,
.records-meta-item span,
.scard-row > span,
.scard-name,
.trust-stat span,
.act-index,
.act-micro,
.scorecard-quality-label,
.scorecard-freq-hero .label,
.stat-card .stat-label,
.aspects-eval-table th,
.aspects-eval-table td:first-child) {
    font-size: var(--trl-micro-size);
    line-height: var(--trl-micro-leading);
    letter-spacing: min(var(--trl-micro-tracking), .1em);
}

/* ═══════════════════════════ FOCUS ═══════════════════════════
   A consistent, visible keyboard affordance.  Static outline only. */

/* .acct-menu-item is absent on purpose: account.css already gives it a
   visible focus treatment (raised background + accent border) and an extra
   outline would change a hand-tuned panel. */
.trl-focus-ring:focus-visible,
.app-nav-btn:focus-visible,
.acct-btn:focus-visible,
.acct-close:focus-visible,
.tour-help-btn:focus-visible,
.tour-close:focus-visible {
    outline: 2px solid var(--trl-focus);
    outline-offset: 2px;
}

/* ═══════════════════════════ COMPONENTS ═══════════════════════════ */

/* Quiet product mark, shown inside an existing header rather than as a new
   full-width app bar.  Deliberately low-contrast: it orients the reader
   without competing with the workspace title beside it. */
.trl-brand-mark {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
    color: var(--trl-dim);
    font-family: var(--trl-mono);
    font-size: var(--trl-micro-size);
    font-weight: 500;
    letter-spacing: var(--trl-micro-tracking);
    line-height: 1;
    text-transform: uppercase;
    text-decoration: none;
}

.trl-brand-mark:hover { color: var(--trl-secondary); }

.trl-brand-mark svg {
    width: 12px;
    height: 12px;
    flex: none;
}

/* Compact secondary utility (e.g. the feedback entry).  Sits below primary
   workspace navigation and never competes with it for attention. */
.trl-utility-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--trl-border);
    border-radius: var(--trl-radius-control);
    background: transparent;
    color: var(--trl-secondary);
    font-family: var(--trl-font);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .02em;
    cursor: pointer;
}

.trl-utility-btn:hover {
    border-color: var(--trl-focus);
    color: var(--trl-text);
}

.trl-utility-btn svg {
    width: 12px;
    height: 12px;
    flex: none;
}

/* Loader context line: says which workspace (and which asset/frequency or
   strategy) the animation is waiting on.  Absolutely positioned so adding it
   cannot move the animated glyph it sits under. */
.trl-loader-context {
    position: absolute;
    left: 50%;
    bottom: 14%;
    transform: translateX(-50%);
    max-width: min(560px, 84vw);
    color: var(--trl-dim);
    font-family: var(--trl-mono);
    font-size: var(--trl-micro-size);
    letter-spacing: var(--trl-micro-tracking);
    line-height: 1.4;
    text-align: center;
    text-transform: uppercase;
    pointer-events: none;
}

.trl-loader-context:empty { display: none; }

/* Status / empty-state surface used by loader and error hand-offs. */
.trl-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 18px 22px;
    border: 1px solid var(--trl-border);
    border-radius: var(--trl-radius-card);
    background: var(--trl-panel);
    box-shadow: var(--trl-shadow);
    color: var(--trl-secondary);
    font-family: var(--trl-font);
    font-size: 12.5px;
    line-height: 1.5;
    text-align: center;
}

.trl-status strong {
    color: var(--trl-text);
    font-weight: 600;
}

/* Action row for retry affordances.  Callers that place this inside a
   message container must re-enable pointer events; the class exists so the
   rule lives in one place instead of being repeated per page. */
.trl-retry-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    pointer-events: auto;
}

.trl-retry-actions button,
.trl-retry-actions a {
    padding: 6px 14px;
    border: 1px solid var(--trl-border);
    border-radius: var(--trl-radius-control);
    background: var(--trl-raised);
    color: var(--trl-text);
    font-family: var(--trl-font);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.trl-utility-btn:focus-visible,
.trl-brand-mark:focus-visible,
.trl-retry-actions button:focus-visible,
.trl-retry-actions a:focus-visible {
    outline: 2px solid var(--trl-focus);
    outline-offset: 2px;
}

.trl-retry-actions button:hover,
.trl-retry-actions a:hover {
    border-color: var(--trl-focus);
}

/* Legend readout.  Its width is reserved from the series it reads (see
   TRLUI.reserveLegendValueWidth), so the value swapping between a
   placeholder and a number can never reflow the legend row — and therefore
   never resize the chart below it — while the pointer moves. */
.trl-legend-value {
    flex: none;
    white-space: nowrap;
}

/* Pre-boot / catastrophic failure panel.  Rendered by ui-core when a shared
   script could not run far enough to reach a page's own error surface, and
   by auth.js when the sign-in SDK itself never loaded. */
#trl-entry-error,
#trl-auth-error {
    position: fixed;
    inset: 0;
    z-index: 2147482000;
    display: grid;
    place-content: center;
    padding: 24px;
    background: var(--trl-ground);
    color: var(--trl-text);
    font-family: var(--trl-font);
}

#trl-entry-error:empty,
#trl-auth-error:empty { display: none; }

:root:has(.trl-loader-preview), body.trl-loader-preview { background: var(--trl-page); }
body.trl-loader-preview { color: var(--trl-secondary); font-family: var(--trl-font); }
.trl-loader-preview h1 { color: var(--trl-text); }
.trl-loader-preview .panel, .trl-loader-preview .tuners, .trl-loader-preview #stage {
    background: var(--trl-panel);
    border-color: var(--trl-border);
}
.trl-loader-preview button {
    color: var(--trl-text);
    background: var(--trl-raised);
    border-color: var(--trl-border);
}
.trl-loader-preview button:hover { background: var(--trl-hover); }
.trl-loader-preview #status { color: var(--trl-dim); }
.trl-preview-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; padding: 14px 20px; }
.trl-preview-nav a { color: var(--trl-secondary); text-decoration: none; font-size: 12px; }
.trl-preview-nav a:hover { color: var(--trl-text); }
.trl-loader-preview .controls button, .trl-preview-nav button {
    padding: 8px 14px;
    border: 1px solid var(--trl-border);
    border-radius: var(--trl-radius-control);
    background: var(--trl-raised);
    color: var(--trl-text);
    font: 12px/1.4 var(--trl-font);
    cursor: pointer;
}
.trl-loader-preview .controls button:hover, .trl-preview-nav button:hover {
    background: var(--trl-hover);
    border-color: var(--trl-focus);
}
.trl-preview-nav :focus-visible { outline: 2px solid var(--trl-focus); outline-offset: 3px; }

/* Preview-only identification.  Applied by the design-preview launcher's
   init script so a reviewer can tell the two windows apart at a glance
   without moving any application geometry. */
html[data-trl-preview] body::after {
    content: attr(data-trl-preview);
    position: fixed;
    right: 10px;
    bottom: 8px;
    z-index: 2147482000;
    padding: 3px 8px;
    border: 1px solid var(--trl-border);
    border-radius: 999px;
    background: var(--trl-panel);
    color: var(--trl-dim);
    font-family: var(--trl-mono);
    font-size: 9px;
    letter-spacing: .12em;
    text-transform: uppercase;
    pointer-events: none;
    opacity: .85;
}

/* ═══════════════════ ASSET CATEGORY HEADINGS ═══════════════════
   Static group labels shared by the Cycle Viewer, Trade Viewer and
   Monitoring Dashboard pickers.  No motion: the list entrance stagger
   deliberately excludes these nodes (see fx.js). */
.trl-asset-category {
    margin: 12px 0 4px;
    padding: 0 12px;
    color: var(--trl-dim);
    font-family: var(--trl-mono);
    font-size: var(--trl-micro-size);
    font-weight: 600;
    line-height: var(--trl-micro-leading);
    letter-spacing: var(--trl-micro-tracking);
    text-transform: uppercase;
}
.trl-asset-category:first-child {
    margin-top: 4px;
}
